********************************************************************************
* Exporting table for multi-country COVID paper (BGD1 sample)
* last updated: 2020-10-12
* Salim Benhachmi
********************************************************************************

clear all
use "$da/BGD1", clear

********************************************************************************

* SES Status
sum hh_consumption, detail
gen higher_ses = (hh_consumption >= `r(p50)')
gen lower_ses = (hh_consumption < `r(p50)')

gen full_sample = 1

********************************************************************************

* Drop in employment
gen drop_empl = (ec_q8_1 == 0 & employment_count_bas != .)

* Drop in income
gen drop_inc = (ec_q12 > ec_q11) if ec_q12 != . & ec_q11 != . 

* Reduced access to markets
gen mkts_clsd = (ec_q2_buying_3 == 1)

* Healthcare access delayed
* N/A

* Missed or reduced meals
gen fd_ins = (ec_q4_mechanism_3 == 1)

* Received NGO or Government Support
gen ngo_gov_sprt = (ec_q4_mechanism_7 == 1)

********************************************************************************

keep if covid_sample == 1

local subgroups higher_ses lower_ses full_sample
local indicators drop_empl drop_inc mkts_clsd fd_ins ngo_gov_sprt

foreach subgroup of local subgroups {
	
	foreach ind of local indicators {
			
		sum `ind' if `subgroup' == 1
		loc mean_`ind'_`subgroup'  : di %10.2fc r(mean)
	}
}

sum covid_sample if higher_ses == 1
loc mean_n_higher_ses :  di %10.0fc r(N)
sum covid_sample if lower_ses == 1
loc mean_n_lower_ses :  di %10.0fc r(N)
sum covid_sample if full_sample == 1
loc mean_n_full_sample :  di %10.0fc r(N)

clear
set obs 3

local indicators drop_empl drop_inc mkts_clsd fd_ins ngo_gov_sprt n

foreach ind of local indicators {	
	gen mean_`ind' = ""
}

foreach ind of local indicators {	
	replace mean_`ind' = "`mean_`ind'_full_sample'" in 1
}

foreach ind of local indicators {	
	replace mean_`ind' = "`mean_`ind'_lower_ses'" in 2
}

foreach ind of local indicators {	
	replace mean_`ind' = "`mean_`ind'_higher_ses'" in 3
}

gen mean_hlth_care_denied = ""

order mean_drop_inc mean_drop_empl mean_mkts_clsd mean_hlth_care_denied ///
	mean_fd_ins mean_ngo_gov_sprt mean_n

export excel using "$dtab/Main Table.xlsx", sheetmodify cell(B6)

********************************************************************************
